<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        .searchCon {
            width: 800px;
            height: 45px;
            margin: 50px auto 0;
            display: block;
            text-indent: 10px;
        }
    </style>
</head>
<body>
    <input class = "searchCon" type="text">
</body>
<script>
    var searchCon = document.getElementsByClassName("searchCon")[0];

    function debounce(callback, delay = 300){
        var timer = null;
        return function(){
            clearTimeout(timer);
            timer = setTimeout(()=> {
                callback.call(this);
            },delay);
        }
    }

    function inputHandler(){
        console.log(this.value,"发送请求");
    }
    searchCon.addEventListener("input",debounce(inputHandler))
</script>
</html>